package com.liujun.io.nio.mysql.protocol;

import java.nio.ByteBuffer;

public class OutTest {

    public static void main(String[] args) {
        int a = 65;

        System.out.println(Integer.toBinaryString(a));

        int b = 0 & 0xff;

        System.out.println(Integer.toBinaryString(b));

        int c = 0 & 0xff << 8;

        System.out.println(Integer.toBinaryString(c));

        int e = 0 & 0xff << 2;

        System.out.println(Integer.toBinaryString(e));

        System.out.println("值" + String.valueOf(0x0A));

        byte[] value = new byte[] { 122, 106, 35, 107, 115, 34, 76, 55 };

        long valuelong = bytesToLong(value);

        System.out.println("转换的值:" + valuelong);

    }

    private static final ByteBuffer buffer = ByteBuffer.allocate(8);

    public static byte[] longToBytes(long x) {
        buffer.putLong(0, x);
        return buffer.array();
    }

    public static long bytesToLong(byte[] bytes) {
        buffer.put(bytes, 0, bytes.length);
        buffer.flip();
        return buffer.getLong();
    }

}
